package com.xidian.zhiancloud.service.myyb;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.SysRoleTableMapper;
import com.xidian.zhiancloud.dao.SysRoleTableMapperExt;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.SysRoleTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 角色管理
 */
@Service
public class IRoleTableService extends ServiceImpl
        <SysRoleTableMapper, SysRoleTable> implements IService<SysRoleTable> {

    @Autowired
    private SysRoleTableMapperExt roleTableMapperExt;

    @Autowired
    private SysRoleTableMapper roleTableMapper;


    public int deleteByPrimaryKey(Long id) {
        return roleTableMapperExt.deleteByPrimaryKey(id);
    }

    public int insert(SysRoleTable record) {
        return roleTableMapperExt.insert(record);
    }

    public int insertSelective(SysRoleTable record) {
        return roleTableMapperExt.insertSelective(record);
    }

    public SysRoleTable selectByPrimaryKey(Long id) {
        return roleTableMapperExt.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(SysRoleTable record) {
        return roleTableMapperExt.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(SysRoleTable record) {
        return roleTableMapperExt.updateByPrimaryKey(record);
    }

    public List<SysRoleTable> selectRoleTableList(Map mapResult) {
        return roleTableMapperExt.selectRoleTableList(mapResult);
    }

    public int deleteRoleTableById(Long id) {
       return roleTableMapperExt.deleteRoleTableById(id);
    }

    /**
     * 修改
     * @param roleTable
     */
    public void patchById(SysRoleTable roleTable) {
        int result = roleTableMapper.updateByPrimaryKeySelective(roleTable);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

    /**
     * 添加
     * @param roleTable
     */
    public void add(SysRoleTable roleTable) {
        int result = roleTableMapper.insert(roleTable);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

}
